const http = require("http");
const fs = require("fs");
const path = require("path");

const server = http.createServer((req, res) => {
    let {
        url,
        method
    } = req;

    if (method === "GET" && url === "/getList") {
        // res.end('okok')
        let filePath = path.join(__dirname, "list.json");
        let content = fs.readFileSync(filePath, "utf8");
        res.setHeader("content-type", "application/json");
        console.log(content);
        res.end(content);
    }
})

server.listen(8001, () => {
    console.log('ok');
})